package com.ckv.qcm.model;

import java.util.ArrayList;

import com.ckv.qcm.model.dao.AnswerDAO;

public class Answer {

	private long id;
	private long idQuestion;
	private String statement;
	private boolean isValid;

	private static AnswerDAO dao = new AnswerDAO();

	public Answer() {
		super();
	}

	public Answer(long id, String statement, boolean isValid) {
		super();
		this.id = id;
		this.statement = statement;
		this.isValid = isValid;
	}

	public Answer(long id, long idQuestion, String statement, boolean isValid) {
		super();
		this.id = id;
		this.statement = statement;
		this.isValid = isValid;
		this.idQuestion = idQuestion;
	}

	public static Answer find(long id, long idQuestion) {
		return ((AnswerDAO) dao).find(id, idQuestion);
	}

	public static ArrayList<Answer> findByQuestion(long idQuestion) {
		return dao.findByQuestion(idQuestion);
	}
	
	public static ArrayList<Answer> findAll() {
		return dao.findAll();
	}

	public Answer create() {
		return dao.create(this);
	}

	public Answer update() {
		return dao.update(this);
	}

	public void delete() {
		dao.delete(this);
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getIdQuestion() {
		return idQuestion;
	}

	public void setIdQuestion(long idQuestion) {
		this.idQuestion = idQuestion;
	}

	public String getStatement() {
		return statement;
	}

	public void setStatement(String statement) {
		this.statement = statement;
	}

	public boolean isValid() {
		return isValid;
	}

	public void setValid(boolean isValid) {
		this.isValid = isValid;
	}

	@Override
	public String toString() {
		return "Answer [id=" + id + ", statement=" + statement + ", isValid="
				+ isValid + "]";
	}

}
